<#include "/common/layout.html"> 
<@layout title="123">
<script type="text/javascript" src="/js/easyui/easyui_grid.js"></script>
<script type="text/javascript">
var datagrid;
var model_name = "/service";
var model_title="售后";
	$(function() {
		
		$("#shop_id").combotree({    
		    url: '/shop/combotree/',  
		    multiple:true,
	    	editable:false,
		    width:400
		});
		
		datagrid=$('#form_datagrid').datagrid({
		 	url:model_name+'/grid',
		 	columns:[[    
		        //{field:'id',title:'编号',checkbox:true},
		        {field:'order_id',title:'订单编号',width:80},
		        {field:'userName',title:'申请用户',width:100},
		        {field:'userPhone',title:'用户手机号',width:100},
		        {field:'shopName',title:'订单所属商家',width:100},
		        {field:'service_type',title:'申请类型',width:70,
		        	formatter:function(value,row,index){
		        		if(row.serviceType=='EXCHANGE'){
			      			return "<font color='blue'>换货</font>";
			      		}else{
			      			return "退货退款";
			      		}
					}
		        },
		        {field:'status',title:'是否处理',width:70,
		        	formatter:function(value,row,index){
			      		if(row.status=='HAS_EXCHANGE'){
			      			return "<font color='blue'>已换货</font>";
			      		}else if(row.status=='HAS_BACK'){
			      			return "<font color='blue'>已退货退款</font>"
			      		}else if(row.status=='HAS_REFUSE'){
			      			return "<font color='blue'>拒绝处理</font>";
			      		}else{
			      			return "未处理";
			      		}
					}
		        },
		        {field:'summary',title:'问题描述',width:120},
		        {field:'reasons',title:'申请理由',width:100},
		        {field:'pic',title:'拍摄图片',width:100},
		        {field:'createdTime',title:'创建时间',width:140},
		        {field:'id',title:'操作',
			        formatter:function(value,row,index){
			        	var restr="";
			        	if(row.status==null || row.status==''){
			        		if(row.serviceType=='EXCHANGE'){
			        			restr = "<a href='#' onclick='audit("+row.id+",\"HAS_EXCHANGE\")'  class='linkbutton' icon='icon-reload' >换&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;货</a>";
			        		}else if(row.serviceType=='BACK'){
			        			restr = "<a href='#' onclick='audit("+row.id+",\"HAS_BACK \")'  class='linkbutton' icon='icon-reload' >退货退款</a>";
			        		}
			        		return restr + " " + "<a href='#' onclick='audit("+row.id+",\"HAS_REFUSE\")'  class='linkbutton' >拒绝</a>";
			        	}
			        }
		        }
		    ]],
		    toolbar : "#service_toolbar",
			onLoadSuccess:function(data){
				$(".linkbutton").linkbutton();
			}
		})
	})
	
	function audit(id_,status) {
		var audit_url= model_name+"/audit/"+id_;
		if(status) audit_url+="-"+status;
		$.messager.confirm('请确认', '确认操作？', function(r) {
			if (r) {
				$.ajax({
					url : audit_url,
					dataType : 'json',
					success : function(r) {
						datagrid.datagrid('load');
						datagrid.datagrid('unselectAll');
						if (r.success) {
							$.messager.show({
								msg:r.msg,
								title:'提示'
							});
							editRow = undefined;
						} else {
							$.messager.alert("操作错误",r.msg,'error');
						}
					}
				});
			}
		});
	}
	
	function exportExcel(){
        var exportForm = document.getElementById('searchForm');
		exportForm.action="/service/excelExport";
		exportForm.submit();
	}
</script>
<script type="text/javascript" src="/js/easyui/easyui_grid_common.js"></script>

</head>
<body  class="easyui-layout">
<div id="imgShow"  style="position: absolute;display:none;border: 4px #ccc solid ;z-index:10;background-color:#fff;padding:5px;">
<img src="" width="150px">
</div>
<div region="north" border="false" title="搜索" collapsed="false"
		style="height: 92px; overflow:hidden;" align="left">
	<div class="tableForm datagrid-toolbar" >
	<form id="searchForm">
		<table style="height: 100%;width:auto;">
			<tr>
				<td>状态</td>
				<td>
					<select id="status" class="easyui-combobox" name="EQ_s.status" style="width:150px;">   
					    <option value="">请选择</option>
					    <option value="YES">已处理</option>   
					    <!-- <option value="DOING">处理中</option> -->   
					    <option value="NO">未处理</option>
					</select>  
				</td>
				<td>订单号</td>
				<td colspan="3"><input type="text" name="EQ_o.id">&nbsp;&nbsp;
				商铺名称&nbsp;<input id="shop_id" name="IN_o.shop_id"/></td>
			</tr>
			<tr>
				<td>用户手机号</td>
				<td><input type="text" name="EQ_u.phone"></td>
				<td>申请时间</td>
				<td>
				<input name="GE_s.created_time"class="easyui-datetimebox" >-<input name="LE_s.created_time"class="easyui-datetimebox" > 
				</td>
				<td>
				<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-search" onclick="_search();">查询</a>
				<a href="javascript:void(0);" class="easyui-linkbutton" onclick="cleanSearch();">取消</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<!-- [<a href="javascript:exportExcel();"><font style="font-size: 13px;">导出Excel</font></a>] -->
				</td>
			</tr>
		</table>
	</form>
	</div>
</div>
<div region="center" border="false">
	<table  id="form_datagrid" >   
	</table>
</div>
<div id="Dialog_"></div>
<div id="service_toolbar">
<script type="text/javascript">
//查看
function serviceView(id_,title){
	if(id_==undefined){
		var rows = datagrid.datagrid('getSelections');
		if (rows.length == 1) {
			id_=rows[0].id;
		}else{
			$.messager.alert('提示', '请选择一条记录！', 'error');
			return;
		}
		serviceOoip(model_name+"/view/"+id_,title);
	}
}
function serviceOoip(url,title){
	$.messager.progress({text:'数据加载中....',interval:100});
	$('#Dialog_').dialog({
	    title: '查看-'+model_title,   
	    width: 810,   
	    height: 500,
	    top:0, 
	    cache: false,
	    maximizable:true,
	    href: url,   
	    modal: true,
	    onLoad:function(){
	    	$.messager.progress('close');
	    },
	    onLoadError:function(){
	    	$.messager.progress('close');
	    },
		buttons:[{
			text:"关闭",
			handler:function() {
				$('#Dialog_').dialog('close');
			}
		}]
	});
}
</script>



<a href="javascript:void(0)" id="grid_toolbar_view" onclick="serviceView();" class="easyui-linkbutton" data-options="iconCls:'icon-redo',plain:true">查看</a>
<a href="javascript:void(0)"  onclick="datagrid.datagrid('reload');" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
<a href="javascript:void(0)"  onclick="datagrid.datagrid('clearSelections');" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true">取消选中</a>
</div>
</body>
</@layout>